<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}



    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/bootstrap-table/bootstrap-table.css"/>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table.js"></script>
    <script src="__STATIC_URL__/static/bootstrap-table/bootstrap-table-zh-CN.js"></script>

    <style>
        thead tr th {
            text-align: center;
        }

        tbody tr td {
            text-align: center;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li><a href="#">卡券管理</a></li>
                <li class="active" style="color: #02b87f;">领卡记录</li>
            </ul>
        </div>
        <div class="panel panel-search panel-default mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title">
                    筛选分类
                </h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">卡券code：</label>
                            <div class="col-sm-9">
                                <!--oninput="getDatas(this.value)" onkeydown="searchkeydown(event,'merchant')"-->
                                <input type="hidden" class="form-control" placeholder="请输入卡号" name="card_id" value="{$card['card_id']}" id="card_id">

                                <input type="text" class="form-control"autocomplete="off" disableautocomplete id="code" placeholder="请输入" value="" name="code">
                                <div class="searchlist hide">
                                    <ul>

                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">时间：</label>
                            <div class="col-sm-9">


                                <input name="search_date" type="text" value="{$p_data['search_date']}"
                                       readonly="readonly" id="search_date" class="form-control"
                                       placeholder="请选择" style="">

                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-9">
                                <select name="statu" class="form-control" id="statu">
                                    <option value="">请选择</option>
                                    <option value="2" >已核销</option>
                                    <option value="0" >未核销</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!--<div class="col-sm-8 col-md-8 col-lg-5">-->
                        <!--<div class="form-group">-->
                            <!--<label class="col-sm-2 control-label">领卡时间：</label>-->
                            <!--<div class="col-sm-9">-->
                                <!--<input name="search_date" type="text" value=""-->
                                       <!--readonly="readonly" id="search_date" class="form-control"-->
                                       <!--placeholder="请选择" style="width: 297px">-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>
        <div class="panel mgl15 mgr15">

            <div class="panel-heading addCharts" style="background:#ededed;">领取记录列表</div>
            <div class="panel-body">
                <table class="table table-bordered" data-toolbar="#toolbar" id="tablelist">

                </table>

            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">核销卡券</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="hexiao">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">门店：</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="id" id="card-id" >
                            <select name="mid" id="he-md" class="form-control" required="required">
                                <option value="">选择门店</option>
                                {volist  name="mach" id="md"}
                                <option value="{$md.id}">{$md.merchant}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">核销员：</label>
                        <div class="col-sm-10">
                            <input type="text" name="nickname" id="nickname" readonly="readonly"  required="required" class="form-control" value="{$user.nickname}">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="hxsure">确认</button>
            </div>
        </div>
    </div>
</div>
</body>
<script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC_URL__/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script src="/wntable.js"></script>
<script>
    //执行一个laydate实例
    // var s=laydate.now();
    laydate.render({
        elem: '#search_date',
        type: 'datetime',
        range: true,
        ready: function(date){
            $(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
            $(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click();
            $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();

        },
        change: function (value, date, date2, data3) {
            var s = value.split(" - ");
            var startdate = new Date(s[0]).getTime();
            var enddate = new Date(s[1]).getTime();
            var ldate = Math.floor((enddate - startdate) / (24 * 3600 * 1000));
            if (ldate > 30) {
                layer.alert("日期区间不能大于31天");
                $("#search_date").val("");
            }
        }
    });
</script>
<script>
    function searchform() {
        $("#tablelist" ).bootstrapTable('refresh');
    }
    $(function () {
        var type = "cardgetlists";
        var url = "{:url()}";
        getcolumn(type, url, "tablelist")
    });
</script>
<script>
    $(function(){
        $("#myModal").on('show.bs.modal',function () {
            var id = $(event.target).attr("data-id");
            // var qx = "{:checkPath('cards/cardconsumes')}";
            // if(qx==0){
            //     layer.alert("没有核销权限");
            //     return false;
            // }
            $("#card-id").val(id);
        });
        $("#myModal").on('hide.bs.modal',function () {
            $("#card-id").val("");
            $("#he-md").val("");
        });
        $("#hxsure").click(function(){
            var mid = $("#he-md").val();
            var nickname = $("#nickname").val();
            if(mid==""){
                layer.alert("请选择门店",{icon:7});
                return false;
            }
            if(nickname==""){
                layer.alert("核销员不能为空",{icon:7});
                return false;
            }
            $.ajax({
                url:"{:url('cards/cardconsumes')}",
                type:"post",
                data:$("#hexiao").serialize(),
                success:function(data){
                    if(data.code==0){
                        layer.msg("核销成功",{icon:1,time:1000});
                        setTimeout("window.location.reload()",1000)
                        return false;
                    }else{
                        layer.alert(data.message,{icon:7});
                        return false;
                    }
                }
            })
        })
    })
</script>

</html>
